package com.xxx.ware.ware_manage_sys.controller;

import com.xxx.ware.ware_manage_sys.bean.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @GetMapping("/testStart")
    public String testStart(){
        return "ok!";
    }

    @GetMapping("/testResClass")
    public ResultVo<List<String>> testResClass(@RequestParam("test_res_flag") String test_res_flag){
        try {
            List<String> resultList = new ArrayList<>();
            if ("1".equals(test_res_flag)) {
                resultList.add("A");
                resultList.add("B");
                resultList.add("C");
            } else {
                resultList.add("D");
                resultList.add("E");
                resultList.add("F");
            }
//            int i = 1/ 0;
            return ResultVo.data(resultList);
        } catch (Exception e) {
            log.error("响应失败，对应失败原因：" + e.getMessage());
            return ResultVo.fail("测试响应类失败");
        }
    }
}
